
  
  <template>
  <el-card class="page pageScroll">
    <el-form
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="机构名称" prop="organizationName">
        <el-input
          v-model="queryParams.organizationName"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery">搜索</el-button>
        <el-button @click="resetQuery">重置</el-button>
        <el-button
          type="success"
          plain
          v-hasPermi="['infra:config:export']"
          @click="onExport"
        >
          导出
        </el-button>
      </el-form-item>
    </el-form>
    <el-tabs v-model="state.tab" style="background: #fff; padding: 10px">
      <el-tab-pane label="全部" name="all"></el-tab-pane>
      <el-tab-pane label="待审核" name="0"></el-tab-pane>
      <el-tab-pane label="审核通过" name="2"></el-tab-pane>
      <el-tab-pane label="审核拒绝" name="1"></el-tab-pane>
    </el-tabs>
    <el-table :data="list" :loading="loading">
      <el-table-column label="序号" align="center" prop="_index" />

      <el-table-column label="公司名称" align="center" prop="organizationName">
      </el-table-column>
      <el-table-column label="所在城市" align="center" prop="cityNameStr">
      </el-table-column>
      <el-table-column label="机构性质" align="center" prop="resourceType">
        <template #default="scope">
          <tag :value="scope.row.resourceType" type="orgResourceType"></tag>
        </template>
      </el-table-column>
      <el-table-column label="联系人" align="center" prop="contactsName">
      </el-table-column>
      <el-table-column
        label="联系方式"
        width="120px"
        align="center"
        prop="contactsPhone"
      >
      </el-table-column>
      <el-table-column label="审核状态" align="center" prop="auditingStatus">
        <template #default="scope">
          <tag
            :value="scope.row.auditingStatus"
            type="auditingStatus"
            style="min-width: 68px"
          ></tag>
        </template>
      </el-table-column>
      <el-table-column
        label="申请时间"
        width="200px"
        align="center"
        prop="createTime"
      >
      </el-table-column>
      <el-table-column label="操作" fixed="right" align="center" width="120px">
        <template #default="scope">
          <el-button link type="primary" @click="toViewPage(scope.row.id)">
            查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination :="pagination" class="padding10" />
  </el-card>
</template>
    
  <script setup lang="ts">
import API from '@/api/api';
import { CONST_VALUE } from '@/utils/const';
import { useTablePage } from '@/hooks/useTablePage';

const router = useRouter();

const state = reactive({
  tab: 'all',
});

const {
  queryParams,
  queryFormRef,
  loading,
  list,
  handleQuery,
  resetQuery,
  handleDelete,
  pagination,
  exportHandle,
} = useTablePage({
  queryApi: API.organizationController.list,
  exportApi: API.organizationController.export,
  queryConfig: {
    refreshDeps: [() => state.tab],
    defaultParams: [
      reactive({
        auditingStatus: computed(() => {
          return state.tab == 'all' ? undefined : state.tab;
        }),
      }),
    ],
  },
});

function toEditPage(id?: number) {
  router.push({
    name: 'editOrganization',
    query: {
      id,
    },
  });
}
function toViewPage(id?: number) {
  router.push({
    name: 'viewOrganization',
    query: {
      id,
    },
  });
}
function onExport() {
  exportHandle({
    fileName: '机构管理',
  });
}
</script>